<template>
	<view class="">
		<view class="isline"></view>
		<scroll-view scroll-y="true">
			<view class="content">
				<view class="profit_top">
					<view :class="day==15?'profit_b active':'profit_b'" @click="clickTab(15)">
						15天
					</view>
					<view :class="day==30?'profit_b active':'profit_b'" @click="clickTab(30)">
						30天
					</view>
				</view>
				<view class="sname">流量趋势</view>
				<view class="charts-box">
					<qiun-data-charts type="area" :opts="opts" :chartData="chartData" />
				</view>
			</view>
		</scroll-view>
		<view class="isline"></view>
		<view class="sname">流量明细</view>
		<scroll-view scroll-y="true" :style="'height: '+scrollheight+'px;'">
			<view class="islist" v-for="(item,index) in flowList" :key="index">
				<view class="">{{item.date}}</view>
				<view class="">{{item.flow}}</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				chartData: {},
				opts: {
					color: ["#5990FF", "#00aa90", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#9A60B4",
						"#ea7ccc"
					],
					padding: [15, 15, 0, 15], // 图位置
					enableScroll: false,
					xAxis: {
						disableGrid: true,
						labelCount: 14, //设置显示个数
						// format: 'formatterTime2'
						fontSize: '9',
						rotateLabel: true,
						marginTop: '5'
						// rotateAngle:'30'
					},
					fontSize: '10',
					dataLabel: false, // 数据显示
					legend: {
						show: false,
					},
					dataPointShape: false, // 圆点显示
					yAxis: {
						gridType: "dash",
						dashLength: 2,
					},
					extra: {
						area: {
							type: "curve",
							opacity: 0.8,
							addLine: true,
							width: 1,
							gradient: true,
							activeType: "hollow"
						}
					}
				},
				chartsDataLine1: {},
				iconInfo: {

				},
				day: 15,
				type: null,
				flowList: [],
				scrollheight: 0
			};
		},
		watch: {},
		onLoad(options) {
			uni.setNavigationBarTitle({
				title: options.name
			})
			this.type = options.type
			this.scrollheight = uni.getWindowInfo().windowHeight - 282
		},
		mounted() {
			// this.xrDom()
		},
		onShow() {
			//模拟从服务器获取数据
			this.getServerData()
		},
		methods: {
			onUecharts() {
				let res = {
					categories: this.chartsDataLine1.date,
					series: [{
						name: "value",
						data: this.chartsDataLine1.flow
					}, ]
				};
				this.chartData = JSON.parse(JSON.stringify(res));
			},
			clickTab(day) {
				this.day = day
				this.chartsDataLine1 = []
				this.getServerData()
			},
			jump(url) {
				this.$fun.jump(url)
			},
			getServerData() {
				this.$fun.ajax.post('user/Kinfo', {
					day: this.day,
					type: this.type
				}).then(res => {
					this.chartsDataLine1 = res.data
					this.flowList = res.data.flowList
					this.onUecharts()
				})
			}
		}
	};
</script>

<style lang="scss">
	page {
		background: #FFFFFF;
	}

	.isline {
		width: 750rpx;
		height: 16rpx;
		background: #F5F1EE;
	}

	.sname {
		font-weight: 600;
		font-size: 28rpx;
		color: #333333;
		margin-left: 30rpx;
		margin-top: 40rpx;
	}

	.content {
		display: flex;
		flex-direction: column;
		flex: 1;
		background: #FFFFFF;
		padding-bottom: 20rpx;



		.profit_top {
			display: flex;
			margin-top: 30rpx;

			.profit_b {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 100rpx;
				height: 48rpx;
				background: #F6F6F6;
				border-radius: 27rpx;
				font-weight: 400;
				font-size: 26rpx;
				color: #333333;
				margin-left: 30rpx;
			}

			.active {
				background: #5990FF;
				font-weight: 600;
				font-size: 26rpx;
				color: #FFFFFF;
			}
		}

		.charts-box {
			width: 100%;
			height: 266rpx;
			padding-right: 30rpx;
		}

		.profit_view {
			height: 100rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background: #FFFFFF;
			padding: 0 30rpx;
			box-sizing: border-box;
			font-size: 30rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: #333333;

			.g {
				color: #333333;
			}

			.r {
				color: #00AA90;
			}
		}

		.profit_list {
			padding: 24rpx 30rpx;
			background: #EEEEEE;

			.profit_title {
				font-size: 30rpx;
				font-family: Microsoft YaHei;
				color: #333333;
			}

			.profit_itemt {
				margin-top: 30rpx;
				height: 80rpx;
				background: #F6F6F6;
				display: flex;
				justify-content: space-between;
				border-radius: 10rpx 10rpx 0rpx 0rpx;
				align-items: center;

				view {
					width: 25%;
					text-align: center;
					font-size: 30rpx;
					font-family: Microsoft YaHei;
					color: #999999;
				}

				view:not(:nth-child(1)) {
					text-align: left;
				}
			}

			.profit_item {
				height: 100rpx;
				background: #FFFFFF;
				display: flex;
				justify-content: space-between;
				border-radius: 10rpx 10rpx 0rpx 0rpx;
				align-items: center;

				view {
					display: flex;
					justify-content: space-between;
					width: 25%;
					font-size: 30rpx;
					font-family: Microsoft YaHei;
					color: #5990FF;
					text-align: center;

					image {
						width: 14rpx;
						height: 24rpx;
						margin-right: 20rpx;
					}
				}

				view:nth-child(1) {
					width: 25%;
					color: #333333;
					display: flex;
					justify-content: center;
				}

				view:not(:nth-child(1)) {
					width: 25%;
					text-align: left;
					color: #5990FF;
				}
			}
		}
	}

	.islist {
		width: 750rpx;
		height: 64rpx;
		line-height: 64rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		font-weight: 400;
		font-size: 24rpx;
		color: #333333;
		display: flex;
		justify-content: space-between;
		padding: 0 30rpx;
	}
</style>